home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13290 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. From: Tony_Bateman@msn.com (Tony Bateman)
  2. Subject: Default Class Initialisation Question...
  3. Date: 24 Mar 96 19:36:28 -0800
  4. Message-ID: <00001a81+0000af6f@msn.com>
  5. Path: news.msn.com!msn.com
  6. Newsgroups: comp.lang.c++
  7. Organization: The Microsoft Network (msn.com)
  8.  
  9. I have a problem concerning default initialisation of classes.
  10.  
  11. If I define a class Rectangle, and have default initialisation values 
  12. in the constructor defined thus:
  13.  
  14. Rectangle::Rectangle(USHORT width=0, USHORT height=0):
  15. itsWidth(width),       
  16. itsHeight(height)
  17. {}
  18.  
  19. then I can define a rectangle to have a width = 30 and height = 0 by 
  20. omitting one of the variables in the initialisation:
  21.  
  22. Rectangle myRectangle(30);
  23.  
  24. Fine. But what if I want to leave the width a default value of 0 and 
  25. set the height to 30. How could I do it? Can it be done in C++ in a 
  26. straightforward manner? Is there anything like a default placeholder 
  27. that can be used?
  28.  
  29.         Regards,
  30.             Tony Bateman.
  31.  
  32. -----------------------------------------------------------------------------
  33. I live in Finland - second highest suicide rate per head of 
  34. population in the world.
  35. It's the beginning of spring - most common time for suicides.
  36. Computer programmering is a recognised high risk suicide profession.
  37. Do NOT spill my pint.....
  38. ----------------------------------------------------------------------------- 
  39.     
  40.